package dlally.view;

import java.awt.Graphics;

import javax.swing.JPanel;

import dlally.model.DecisionLinesEvent;
/**
 * A custom JPanel to handle drawing lines and edges
 * @author Douglas Lally (dlally@wpi.edu)
 *
 */
@SuppressWarnings("serial")
public class GameFieldPanel extends JPanel {
	/**
	 * Each panel will need to know the number of lines to be drawn, as well as the x position of the first line and the y positions of all of the lines
	 * It needs to have an associated model, so it can figure out how many lines to draw
	 */
	int numLines;
	int xpos = 50;
	int ytop = 0;
	int ybottom = 300;
	

	DecisionLinesEvent model;
	/**
	 * Constructor, used to figure out how many lines to draw
	 * @param m the model to draw lines for
	 */
	public GameFieldPanel(DecisionLinesEvent m){
		this.model = m;
		numLines = m.getNumPlayers();
	}
	
	@Override
	/**
	 * Paints the appropriate number of lines with 100 pixel gaps between them
	 */
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		
		for(int i = 0; i < numLines; i++)
			g.drawLine(xpos + (100*i),ytop,xpos + (100*i),ybottom);

	}
	/**
	 * Draws a line with the given coordinates, used for adding edges
	 * @param x1 x coordinate of first point
	 * @param y1 y coordinate of first point
	 * @param x2 x coordinate of second point
	 * @param y2 y coordinate of second point
	 */
	public void addLine(int x1, int y1, int x2, int y2){
		Graphics g = this.getGraphics();
		g.drawLine(x1,y1,x2,y2);
	}
	


}
